﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Interfleet.SE.UICompiler.Core.YahooCssCompressor
{
    /// <summary>
    /// Result builder for the Yahoo Css Compressor.
    /// </summary>
    public class YCResultBuilder : ResultBuilder
    {
        internal YCResultBuilder(Arguments arguments)
            : this(arguments, new FileProvider())
        {

        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="arguments"></param>
        /// <param name="fileInfoProvider"></param>
        public YCResultBuilder(Arguments arguments, IFileProvider fileInfoProvider)
            : base(arguments, fileInfoProvider)
        {
            
        }

        public override CompileResult Build(string cssResult, DateTime compilationStartedAt)
        {
            var result = new CompileResult(Arguments.Files, Arguments.CompiledFileName);
            FileInfoProvider.SaveToFile(Arguments.CompiledFileName, cssResult);
            result.Success = true;
            result.StatusMessage = string.Concat("Compiled file: ", Arguments.CompiledFileName);
            return result;
        }
    }
}
